<?php $id = getId(); ?>
<div class="x-list-title">
<table width="100%" border="0" height="100%">
<tr><td align="left">
	<h2><?php _e($title)?></h2>
</td><td align="right">
<div class="x-list-options">
	<div class="x-pop">
		<form action="<?php _baseUrl()?><?php if($this->getAction() == 'Share') _e('/Contact/Index/Share'); else _e('/Contact/Index/Search');?>" onsubmit="return ajax_form(this,true)">
		<div class="simple-search">
			<input type="text" name="s" class="s" autocomplete="off" spellcheck="false" placeholder="Tìm kiếm"/>
			<button class="b"></button>
		</div>
		</form>
	</div>
	<div class="x-options-container">
		<a class="x-button">Liên hệ mới <span>&#9660;</span></a>
		<div class="x-options">
			<a class="x-options-item" href="#Contact/Index/Addcompany">Thêm công ty</a>
			<a class="x-options-item" href="#Contact/Index/Addperson">Thêm cá nhân</a>
		</div>
	</div>		
	<?php if( $this->getActionName() == 'indexAction'): ?>
	
	<div class="x-options-container">
		<a class="x-button">Di chuyển tới <span>&#9660;</span></a>
		<div class="x-options">
			<?php foreach( $this->get('labels') as $b ): ?>
			<a class="x-options-item" onclick="module_ajax('<?php _baseUrl()?>/Contact/Index/Movelabel?label_id=<?php _e($b['ID'])?>','f<?php _e($id);?>',this)"><?php _e($b['label'])?></a>
			<?php endforeach;?>		
			<a class="x-options-item" onclick="load_inframe('<?php _baseUrl();?>/Contact/Index/Label',{title: 'Quản lý nhãn liên hệ', css_content: 'width:420px;height:300px;overflow:auto;max-height:300px' })">Quản lý nhãn</a>			
		</div>
	</div>
	
	<div class="x-options-container">
		<a class="x-button">Gán nhãn <span>&#9660;</span></a>
		<div class="x-options">
			<?php foreach( $this->get('labels') as $b ): ?>
			<a class="x-options-item" onclick="module_ajax('<?php _baseUrl()?>/Contact/Index/Addlabel?label_id=<?php _e($b['ID'])?>','f<?php _e($id);?>',this)"><?php _e($b['label'])?></a>
			<?php endforeach;?>		
			<a class="x-options-item" onclick="load_inframe('<?php _baseUrl();?>/Contact/Index/Label',{title: 'Quản lý nhãn liên hệ', css_content: 'width:420px;height:300px;overflow:auto;max-height:300px' })">Quản lý nhãn</a>
		</div>
	</div>
	<?php endif;?>
	<div class="x-options-container">
		<a class="x-button">Tác vụ khác <span>&#9660;</span></a>
		<div class="x-options">
			<a class="x-options-item" href="#Contact<?php if($this->getAction() == 'Share') _e('/Index/Share');?>?type=person">Liên hệ cá nhân</a>
			<a class="x-options-item" href="#Contact<?php if($this->getAction() == 'Share') _e('/Index/Share');?>?type=company">Liên hệ công ty</a>
			<?php
				$vars = $this->get('vars');
				unset($vars['p']);
				$url = '#'.$this->module."/".$this->controller."/".$this->action;
				if( count($vars) > 0 )
					$url = $url.'?'.to_query_configs($vars);
			?>			
			<a class="x-options-item" onclick="module_delete('<?php _baseUrl()?>/Contact/Index/Delete?url=<?php _e(rawurlencode($url));?>','f<?php _e($id);?>',this)">Xóa đã chọn</a>
			
		</div>
	</div>	
</div>
</td></tr></table>	
</div>
<?php
$vars = $this->get('vars');
$link = '#'.$this->module."/".$this->controller."/".$this->action;
?>
<form action="<?php _baseUrl()?>/Task/Act" method="post" id="f<?php _e($id);?>">
<table width="100%" class="x-list" cellpadding="0" cellspacing="0">
<tr>
	<th width="25" align="center">
		TT
	</th>
	<th align="center">
		<?php show_order_link('Tên giao dịch','title',$link,$vars) ;?>
	</th>
	<th align="center" width="210">
		<?php show_order_link('Địa chỉ','address',$link,$vars) ;?>
	</th>
	<th align="center" width="80">
		<?php show_order_link('Phone','phone',$link,$vars) ;?>
	</th>
	<th align="center" width="100">
		<?php show_order_link('Fax','fax',$link,$vars) ;?>
	</th>
	<th align="center" width="160">
		<?php show_order_link('Email','email',$link,$vars) ;?>
	</th>
	<th align="center" width="50" colspan="2">Tác vụ</th>
	<th align="center" width="25">
		<div class="x-check-container">
			<div class="x-check">
			<input type="checkbox" class="x-checkbox x-checkall"/>
			</div>
			<div class="x-check-options">
				<a class="x-check-item check-all">Chọn tất cả</a>
				<a class="x-check-item uncheck-all">Bỏ chọn</a>
			</div>
		</div>
	</th>
</tr>
<?php if( count($this->get("posts")) > 0 ): ?>
<?php foreach( $this->get("posts") as $k => $a ): ?>
	<tr>
	<td align="center">
		<?php _e($k+1);?>
	</td>
	<td>
		<a href="#Contact/Index/View<?php _e( $a['type'] =='person' ? 'person' :'company' );?>?ID=<?php _e($a['ID']);?>">
			<?php if( $a['type'] =='company' ):?><img src="<?php _baseUrl();?>/style/images/company.png"/><?php endif;?> <?php _e(short_title($a['title'],35));?>
		</a>
	</td>
	<td align="center">
		<?php _e( $a['address'] )?>
	</td>
	<td align="center">
		<?php _e( $a['phone'] )?>
	</td>

	<td align="center">
		<?php _e( $a['fax'] )?>
	</td>

	<td>
		<?php _e( $a['email'] )?>
	</td>
	<td align="center" width="25">
		<?php if( $a['created_by_id'] == get_user_id() ):?>
		<a onclick="module_delete('<?php _baseUrl()?>/Contact/Index/Delete?<?php _e( $a['type'] =='person' ? 'person' :'company' );?>ID[]=<?php _e($a['ID'])?>&url=<?php _e(rawurlencode($url));?>')" class="x-delete"></a>
		<?php else:?>
		<a class="x-nodelete"></a>
		<?php  endif;?>
	</td>
	<td align="center" width="25">
		<?php if( $a['created_by_id'] == get_user_id() ):?>
		<a href="#Contact/Index/Edit<?php _e( $a['type'] =='person' ? 'person' :'company' );?>?ID=<?php _e($a['ID'])?>" class="x-edit"></a>
		<?php else: ?>
		<a class="x-noedit"></a>
		<?php  endif;?>		
	</td>

	<td align="center">
		<?php if( $a['created_by_id'] == get_user_id() ):?>
		<input name="<?php _e( $a['type'] =='person' ? 'person' :'company' );?>ID[]" value="<?php _e($a['ID'])?>" type="checkbox" class="x-checkbox x-checkall"/>
		<?php else: ?>
		<input type="checkbox" disabled/>
		<?php  endif;?>				
	</td>
	</tr>
	<?php endforeach;?>
	<tr>
		<td colspan="9" class="page">
		<div class="x-page">
			<?php $this->e("page");?>
		</div>		
		</td>
	</tr>
	<?php else:?>
	<tr>
		<td colspan="9" class="page"><div class="x-page">
				Không có bản ghi nào được tìm thấy
			</div>
		</td>
	</tr>
	<?php endif;?>
</table><br/><br/>
</form>